// WaitBox.cpp : implementation file
//

#include "stdafx.h"
#include "WaveAnalysis.h"
#include "WaitBoxHelper.h"
#include "WaitBox.h"


// WaitBox dialog

IMPLEMENT_DYNAMIC(WaitBox, CDialog)

WaitBox::WaitBox(CWnd* pParent /*=NULL*/)
	: CDialog(WaitBox::IDD, pParent)
	, strprompt(_T(""))
{

}

WaitBox::~WaitBox()
{
}

void WaitBox::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(WaitBox, CDialog)
	ON_WM_CREATE()
	ON_WM_CLOSE()
	ON_WM_TIMER()
END_MESSAGE_MAP()


// WaitBox message handlers

void WaitBox::SetDefaultPrompt(LPCTSTR str)
{
	strprompt=str;

}

int WaitBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  Add your specialized creation code here

	return 0;
}

BOOL WaitBox::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
	CStatic *p=(CStatic *)this->GetDlgItem(IDC_PROMPT);
	p->SetWindowTextW(strprompt.GetBuffer());
//	SetWindowPos(HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
	BeginWaitCursor();
	SetTimer(1,500,0);
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void WaitBox::OnClose()
{
	// TODO: Add your message handler code here and/or call default
	KillTimer(1);
	EndWaitCursor();
	CDialog::OnClose();
}

void WaitBox::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: Add your message handler code here and/or call default
	static int count=0;
	if(nIDEvent==1){
		CString s=L"Please Wait ";
		for(int i=0;i<count;i++)
			s.AppendChar('.');
		count=(++count)%4;
		CStatic *p=(CStatic *)this->GetDlgItem(IDC_SWAIT);
		p->SetWindowTextW(s.GetBuffer());
	}
	CDialog::OnTimer(nIDEvent);
}
